#ifndef LINEEDITPOPUPSHELL_H
#define LINEEDITPOPUPSHELL_H

#include "LineEditShell.h"
#include <QAbstractButton>
#include <QListWidget>
#include "../../XXqtDefine.h"
#include "../../Utils/XXlayoutConstraint.h"

#include <QSharedPointer>

class LineEditPopupShell : public LineEditShell
{
    Q_OBJECT
public:
    explicit LineEditPopupShell(QObject *parent = nullptr);

    XX_KEY(kLineEdit)
    XX_KEY(kListWidget)
    XX_KEY(kIndicatorButton)
    void shell(QLineEdit *lineEdit, QAbstractButton *button, QListWidget *listWidget);
    void configPopupListItem(const QStringList &list);

protected:
    virtual bool eventFilter(QObject *w, QEvent *e);
    virtual void installObject(const QString &name, QObject *object);
    virtual void uninstallObject(const QString &name, QObject *object);
    virtual void active(bool enable);
    virtual void popup(bool enable);

    QLineEdit* lineEdit();
    QListWidget* listWidget();
    QAbstractButton* indicatorButton();

private:
    Q_SLOT void indicatorButton_onClicked(bool checked);
    Q_SLOT void listWidget_onItemDblClicked(QListWidgetItem *item);

private:
    QStringList _popupList;
    QList<QSharedPointer<XXlayoutConstraint>> _listWidgetLayout,_buttonLayout;
};

#endif // LINEEDITPOPUPSHELL_H
